var phoneOK=true;
var consigneeOK=true;
var cityselectOK=true;
var addressOK=true;
var zipcodeOK=true;

function verifyaddress(){
	isphone(phone.value);
	isconsignee(name.value);
	iscityselected();
	isaddress(address.value);
	isZIPcode(zipcode.value);
	if(phoneOK && consigneeOK  && cityselectOK && addressOK && zipcodeOK)return true;
}

function isphone(s){
	phoneOK=true;
	if(!s) {
		$("#phonediv").hide();
		return;
	}
	var input=s.trim();
	var patrn=/^[+]?[0-9\-]{7,}$/; 
	if(input.length==0){ $("#phonediv").hide();}
	else if (!patrn.exec(input)){phonediv.innerHTML="电话号码不符合规范";$("#phonediv").show();phoneOK=false;}
	else {
		$("#phonediv").hide();
	}
}

function isconsignee(s){
	consigneeOK=true;
	if(!s) {
		return;
	}
	var input=s.trim();
	if(input.length==0) consigneeOK=false;
}

function iscityselected(){
	cityselectOK=true;
	if((!($("#province").val()=="请选择所在省份"))&&($("#city").val()=="请选择所在城市")){
		cityselectOK=false;
	}
	var a=document.getElementById("province");
	var b=a.selectedIndex;
	if(b==1||b==2||b==3||b==25||b==28||b==30){
		cityselectOK=true;
	}
}

function isaddress(s){
	addressOK=true;
	if(!s) {
		return
	}
	var input=s.trim();
	if(input.length==0) addressOK=false;
}

function isZIPcode(s){
	zipcodeOK=true;
	if(!s) {
		return
	}
	var input=s.trim();
	var patrn=/^\d{6}$/; 
	if (!patrn.exec(input)){
		zipdiv.innerHTML="邮政编码为6位数字";
		$("#zipdiv").show();
		zipcodeOK=false;
	}
	else{
		$("#zipdiv").hide();
	}
}